"""
测试招商后台系统测试环境

"""
import unittest

from selenium import webdriver
import time
import ddddocr
from selenium.webdriver.common.by import By


class TsetZhaoShangCase(unittest.TestCase):

    def test_01(self):
        options = webdriver.ChromeOptions()
        options.add_experimental_option("detach", True) # 设置执行完后不关闭浏览器

        driver = webdriver.Chrome(options=options)
        # 打开招商后台系统
        driver.get("http://10.124.130.201:8200/#/login")
        time.sleep(2)
        # 输入账号
        driver.find_element(By.XPATH, "//input[@placeholder='账号']").send_keys("admin")
        # 输入密码
        driver.find_element(By.XPATH, "//input[@placeholder='密码']").send_keys("123456")
        # 找到图片并保存
        pic = driver.find_element("css selector", 'img')
        # 实例对象
        ocr = ddddocr.DdddOcr()
        contex = ocr.classification(pic.screenshot_as_png)
        # 输入验证码
        driver.find_element(By.XPATH, "//input[@placeholder='验证码']").send_keys(eval(contex[0: 3]))
        # 点击登陆
        # driver.find_element(By.XPATH, "//*[@id='app']/div/div[1]/form/div[4]/div/button/span/span").click()

